<?php
$title = ucfirst($mode) . ' Biller';
?>
<?php require('inc-header.php'); ?>


<p><?php echo validation_errors(); ?></p>

<?php echo form_open(current_url()); ?>
<?php echo form_hidden('id', $id); ?>
<table>
    <!-- Name -->
    <tr>
        <td>
            <?php echo form_label('Name', 'name'); ?></td><td>
            <?php echo form_input('name', $name); ?>
        </td>
    </tr>
    <!-- Amount -->
    <tr>
        <td>
            <?php echo form_label('Amount', 'amount'); ?>
        </td>
        <td>
            <?php echo form_input('amount', $amount); ?>
        <td>
    </tr>
    <!-- Recurrence -->
    <tr>
        <td>
            <?php echo form_label('Recurrence', 'freq'); ?>
        </td>
        <td>
            <?php
            $options = array(
                'M' => 'Monthly',
                'W' => 'Weekly'
            );
            $extra = 'id="freq"';

            echo form_dropdown('freq', $options, $freq, $extra);
            ?>
        </td>
    </tr>
    <!-- Weekly -->
    <tr>
        <td>
            <div class="W">
                <?php echo form_label('Day of the Week', 'byday'); ?>
            </div>
        </td>
        <td>
            <div class="W">
                <?php
                $options = array(
                    'SU' => 'Sunday',
                    'MO' => 'Monday',
                    'TU' => 'Tuesday',
                    'WE' => 'Wednesday',
                    'TH' => 'Thursday',
                    'FR' => 'Friday',
                    'SA' => 'Saturday'
                );
                $extra = 'id="byday"';

                echo form_dropdown('byday', $options, $byday, $extra);
                ?>  
            </div>
        </td>
    </tr>

    <!-- Yearly and Monthly -->
    <tr>
        <td>
            <div class="M">
                <?php echo form_label('Day of the Month', 'bymonthday'); ?>
            </div>
        </td>
        <td>
            <div class="M">
                <?php
                $options = array(
                    '1' => '1',
                    '2' => '2',
                    '3' => '3',
                    '4' => '4',
                    '5' => '5',
                    '6' => '6',
                    '7' => '7',
                    '8' => '8',
                    '9' => '9',
                    '10' => '10',
                    '11' => '11',
                    '12' => '12',
                    '13' => '13',
                    '14' => '14',
                    '15' => '15',
                    '16' => '16',
                    '17' => '17',
                    '18' => '18',
                    '19' => '19',
                    '20' => '20',
                    '21' => '21',
                    '22' => '22',
                    '23' => '23',
                    '24' => '24',
                    '25' => '25',
                    '26' => '26',
                    '27' => '27',
                    '28' => '28',
                );
                $extra = 'id="bymonthday"';

                echo form_dropdown('bymonthday', $options, $bymonthday, $extra);
                ?> 

            </div>
        </td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td>

            <?php echo form_submit('save', '  Save  '); ?>
            <?php echo form_submit('cancel', '  Cancel  '); ?>

        </td>
    </tr>
</table>

<?php if ($mode == 'edit'): ?>
    <div style="text-align:right;">
        <?php echo anchor('billstream/delete?id=' . $id, 'Delete'); ?>
    </div>
<?php endif; ?>


<?php echo form_close(); ?>




<?php require('inc-footer.php'); ?>